/** 
 * -------------------------------------------------------------------------------
 * NoiseTube - Mobile client (J2ME version)
 * Copyright (C) 2008-2010 SONY Computer Science Laboratory Paris
 * 
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License, version 2.1,
 * as published by the Free Software Foundation.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * --------------------------------------------------------------------------------
 * 
 * Full GNU LGPL v2.1 text: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 * NoiseTube project source code repository: http://code.google.com/p/noisetube
 * NoiseTube project website: http://www.noisetube.net
 */

package noisetube.io;

import java.util.Enumeration;
import java.util.Vector;

import noisetube.model.Measure;

/**
 * @author mstevens
 * 
 */
public class MultiSaver extends Saver
{

	Vector savers;

	public MultiSaver()
	{
		savers = new Vector();
	}

	public void addSaver(Saver saver)
	{
		savers.addElement(saver);
	}

	/**
	 * @see noisetube.io.Saver#save(noisetube.model.Measure)
	 */
	public void save(Measure measure)
	{
		Enumeration saverEnum = savers.elements();
		while(saverEnum.hasMoreElements())
			((Saver) saverEnum.nextElement()).save(measure);
	}

	/**
	 * @see noisetube.util.IService#start()
	 */
	public void start()
	{
		Enumeration saverEnum = savers.elements();
		while(saverEnum.hasMoreElements())
			((Saver) saverEnum.nextElement()).start();
		running = true;
	}

	/**
	 * @see noisetube.util.IService#stop()
	 */
	public void stop()
	{
		running = false;
		Enumeration saverEnum = savers.elements();
		while(saverEnum.hasMoreElements())
			((Saver) saverEnum.nextElement()).stop();
	}

}
